let App = getApp();  
Page({  
  data: {   
      username: "",  
      phone: "",  
      wechart: "",
      positionname:"",
      positionnamedetail:"",
      longitude:"",
      latitude:"",  
  },  
  formSubmit: function (e) {  
    let that = this;
      //console.log('form发生了submit事件，携带数据为：', e.detail.value);  
      let { username,phone, wechart, positionname,positionnamedetail } = e.detail.value;  
      if (!phone) {  
        wx.showModal({
          title: '温馨提示',
          content: "请填写手机号",
          showCancel: false,
          success: function (res) {
           return true;
          }
        });
        return;  
      }  
      if (!username) {  
        wx.showModal({
          title: '温馨提示',
          content: "请填写姓名",
          showCancel: false,
          success: function (res) {
           return true;
          }
        });
        return;  
      }  
      if (!positionname) {  
        wx.showModal({
          title: '温馨提示',
          content: "请选择地址",
          showCancel: false,
          success: function (res) {
           return true;
          }
        });
        return;  
      }  

      //发起请求
      App._post('apply/addTzinfo', {
        username:username,
        phone:phone,
        wechart:wechart,
        positionname:that.data.positionname,
        positionnamedetail:that.data.positionnamedetail,
        longitude:that.data.longitude,
        latitude:that.data.latitude,
      }, function (result) {
      }) 
  },  
  formReset: function () {  
    console.log('form发生了reset事件')  
  },
  openmap: function (e) {
    var that = this;
    wx.getLocation({
      type: 'gcj02', //返回可以用于wx.openLocation的经纬度
      success: function (res) {
        var latitude = res.latitude
        var longitude = res.longitude
        var ugetaddress = 'userData.ugetaddress'
        wx.chooseLocation({
          success: function (res) {
            console.log(res);
            var address_name = res.name;
            var address_info = res.address;
            that.setData({
              latitude: res.latitude,
              longitude: res.longitude,
              positionname: address_name,//将解析后的地址进行存储
              positionnamedetail: address_info//将解析后的地址进行存储
            })
          },
          fail: function () {
            console.log(res);
          },
          complete: function () {
            // complete
          }
        })
      }
    })
  },
})